-
Notifications
You must be signed in to change notification settings - Fork 63
feat: add support for np.isnan and np.isfinite ufuncs
#2188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit implements the `isnan` and `isfinite` numpy ufuncs in bigframes. The following changes were made: - Added `IsNanOp` and `IsFiniteOp` to `bigframes/operations/numeric_ops.py` - Mapped `np.isnan` and `np.isfinite` to the new ops in `bigframes/operations/numpy_op_maps.py` - Added compilation logic for the new ops to the ibis, polars, and sqlglot compilers - Added tests for the new ops in `tests/system/small/test_numpy.py`
This commit implements the `isnan` and `isfinite` numpy ufuncs in bigframes. The following changes were made: - Added `IsNanOrNullOp` and `IsFiniteOp` to `bigframes/operations/numeric_ops.py` - Mapped `np.isnan` and `np.isfinite` to the new ops in `bigframes/operations/numpy_op_maps.py` - Added compilation logic for the new ops to the ibis, polars, and sqlglot compilers - Added tests for the new ops in `tests/system/small/test_numpy.py` - Renamed `IsNanOp` to `IsNanOrNullOp` to match numpy semantics and updated compilers accordingly.
bigframes/operations/numeric_ops.py
Outdated
| unsafe_pow_op = UnsafePowOp() | ||
|
|
||
| IsNanOp = base_ops.create_unary_op( | ||
| name="isnanornull", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 7f1bca4, thanks.
| @polars_compiler.register_op(numeric_ops.IsNanOp) | ||
| def is_nan_op_impl( | ||
| compiler: polars_compiler.PolarsExpressionCompiler, | ||
| op: numeric_ops.SqrtOp, # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type annotation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 7f1bca4, thanks.
| @polars_compiler.register_op(numeric_ops.IsFiniteOp) | ||
| def is_finite_op_impl( | ||
| compiler: polars_compiler.PolarsExpressionCompiler, | ||
| op: numeric_ops.SqrtOp, # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
annotation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 7f1bca4, thanks.
This commit implements the
isnanandisfinitenumpy ufuncs in bigframes.The following changes were made:
IsNanOpandIsFiniteOptobigframes/operations/numeric_ops.pynp.isnanandnp.isfiniteto the new ops inbigframes/operations/numpy_op_maps.pytests/system/small/test_numpy.pyThank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes b/454341854🦕